// http消息处理 接收到http消息在这处理
// @ts-ignore
await execute();
async function execute() {
    let message = ClientUtils.get_client_message_string();
    let message_json;
    try {
        message_json = JSON.parse(message);
    } catch (e) {
        console.warn("http message json序列化失败");
        return "非法请求";
    }
    // 请求内容
    if (typeof message_json["body"] === 'string') {
        try {
            message_json["body"] = JSON.parse(message_json["body"]);
        } catch (e) {
            console.warn("body json序列化失败");
        }
    }
    // query请求编号
    let query_code = message_json["query"]['code'];
    if (_HttpHandlerData.has(query_code)) {
        let handler_script = _HttpHandlerData.get(query_code);
        return await handler_script.execute(message_json);
    }
    // body请求编号
    let body_code = message_json["body"]['code'];
    if (_HttpHandlerData.has(body_code)) {
        let handler_script = _HttpHandlerData.get(body_code);
        return await handler_script.execute(message_json);
    } else {
        console.warn(`http/${body_code}.js notfound`);
        return "非法请求";
    }
}